package com.aliothservice.catfish.device.data;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.data.annotation.Id;

public class HumidityDocument {
	
	public Map<String, Object> toMap() {
		Map<String, Object> map = new HashMap<String, Object>();
		DateFormat fullFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
		map.put("recordingStart", fullFormatter.format(this.getRecordingStart()));
		if (null != this.getRecordingEnd()) {
			map.put("recordingEnd", fullFormatter.format(this.getRecordingEnd()));
		}
		if (null != this.getHumidityObjects()) {
			List<Map<String, Object>> objectList = new ArrayList<Map<String, Object>>();
			for (HumidityObject object : this.getHumidityObjects()) {
				objectList.add(object.toMap());
			}
			map.put("humidityObjects", objectList);
		}
		
		return map;
	}

	@Id
	private String id;
	
	private String orderId;
	private List<String> viewers;
	private Date recordingStart;
	private Date recordingEnd;
	
	private List<HumidityObject> humidityObjects;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getOrderId() {
		return orderId;
	}

	public void setOrderId(String orderId) {
		this.orderId = orderId;
	}

	public List<String> getViewers() {
		return viewers;
	}

	public void setViewers(List<String> viewers) {
		this.viewers = viewers;
	}

	public Date getRecordingStart() {
		return recordingStart;
	}

	public void setRecordingStart(Date recordingStart) {
		this.recordingStart = recordingStart;
	}

	public Date getRecordingEnd() {
		return recordingEnd;
	}

	public void setRecordingEnd(Date recordingEnd) {
		this.recordingEnd = recordingEnd;
	}

	public List<HumidityObject> getHumidityObjects() {
		return humidityObjects;
	}

	public void setHumidityObjects(List<HumidityObject> humidityObjects) {
		this.humidityObjects = humidityObjects;
	}
	
}
